import { z } from "zod"; import { withUser, parseBody, json } from "@/lib/api"; import { getConversationWithMessages, updateConversation, deleteConversation } from "@/lib/conversations/service"; export const dynamic = "force-dynamic"; type P = { id: string }; export const GET = withUser
(async ({ user }, { id }) => json(await getConversationWithMessages(user.id, id))); const patchSchema = z.object({ title: z.string().max(200).optional(), pinned: z.boolean().optional(), archived: z.boolean().optional(), folderId: z.string().max(64).nullable().optional(), projectId: z.string().max(64).nullable().optional(), systemPrompt: z.string().max(50_000).nullable().optional(), settings: z.record(z.string(), z.unknown()).optional(), modelKey: z.string().max(120).nullable().optional(), }); export const PATCH = withUser
(async ({ req, user }, { id }) => { const body = await parseBody(req, patchSchema); return json({ conversation: await updateConversation(user.id, id, body) }); }); export const DELETE = withUser
(async ({ user }, { id }) => { await deleteConversation(user.id, id); return json({ ok: true }); });